package com.ews.onlineexchange.controller;

import javax.enterprise.inject.Model;
import javax.inject.Inject;

import com.ews.onlineexchange.dao.ServiceSupplierDao;
import com.ews.onlineexchange.model.ServiceSupplier;
import com.ews.onlineexchange.model.User;
import com.ews.onlineexchange.service.UserService;

@Model
public class LoginedServiceSupplierController {
	
	@Inject
	ServiceSupplierDao		serviceSupplierDao;

	@Inject
	UserService				userService;

	@Inject
	ServiceSupplierHome		serviceSupplierHome;

	private ServiceSupplier	serviceSupplier;
	
	public void init() {
		User loginedUser = userService.getLoginedUser();
		
		serviceSupplierHome.setId( loginedUser.getId() );
		serviceSupplierHome.loadInstance();
//		serviceSupplier = serviceSupplierDao.find(loginedUser.getId());	
//		serviceSupplier.getAttachments().size();
//		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		
//		for ( MainBusiness _mb : serviceSupplier.getMainBusinesses() ) {
//			_mb.getImages().size();
//		}
	}

	public ServiceSupplier getServiceSupplier() {
		return serviceSupplier;
	}

	public void setServiceSupplier(ServiceSupplier serviceSupplier) {
		this.serviceSupplier = serviceSupplier;
	}	
	
}
